(define-module (fiio gradle)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix build-system trivial)
  #:use-module (guix download)
  #:use-module (guix packages)
  #:use-module (gnu packages compression))

(define-public gradle
  (package
    (name "gradle")
    (version "5.6.2")
    (source (origin
              (method url-fetch)
              (uri (string-append
                    "https://services.gradle.org/distributions/gradle-"
                    version "-bin.zip"))
              (sha256
               (base32
                "1q4ybm59y3bwi9s2prpz226843bxns6sw19jmnq9kxs8i1ifdz1j"))))
    (build-system trivial-build-system)
    (arguments
     `(#:builder (begin
                   (use-modules (guix build utils))
                   (let* ((unzip
                           (string-append (assoc-ref %build-inputs "unzip")
                                          "/bin/unzip"))
                          (source (assoc-ref %build-inputs "source"))
                          (out    (assoc-ref %outputs "out"))
                          (zipdir (string-append out "/"  ,(string-append name "-" version))))
                     (mkdir-p out)
                     (symlink out zipdir)
                     (with-directory-excursion out
                       (invoke unzip source))
                     (delete-file zipdir)
                     #t))
       #:modules ((guix build utils))))
    (native-inputs `(("unzip" ,unzip)))
    (home-page "https://gradle.org")
    (synopsis "Build system")
    (description "Gradle helps teams build, automate and deliver
better software, faster.")
    (license license:asl2.0)))
